package com.controller;

import com.domain.tab_user;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @Author: 许磊磊
 * @Date: 2022/10/18 19:47
 * @Version 1.0
 */
@RestController
public class UserController {

    private UserService userService;

    @Autowired
    public void setUserService(UserService userService){
        this.userService=userService;
    }

    @GetMapping("/find_all")
    public Flux<tab_user> findAll(){
        return userService.findAll();
    }

    @GetMapping("/find_one/{id}")
    public Mono<tab_user> findOne(@PathVariable String id){
        return userService.findOne(id);
    }

    @PostMapping("/update_one")
    public Mono<Integer> updateOne(tab_user user){
        return  userService.updateOne(user);
    }

    @GetMapping("/delete_one/{uid}")
    public Mono<Integer> deleteOne(@PathVariable String uid){

        return userService.deleteOne(uid);
    }

    @PostMapping("/insert_one")
    public Mono<Integer> insertOne(tab_user user){
        return userService.insertOne(user);
    }
}
